{% load get_page %}
{% load objIndex %}

{% extends 'beastly/base.html' %}
{% block extrastyle %}
<link rel="stylesheet" type="text/css" media="screen" href="{{ media_url }}beastly/css/topics.css" />
{% endblock %}

{% block page_title %}
<h2>{{ forum.title }}</h2>
<p>{{ forum.topic_set.count }} topics and {{ forum.post_count }} posts</p>
{% endblock %}

{% block content %}
<table class="topics">
	<tr>
		<th colspan="2">Topic</th>
		<th>Posts</th>
		<th>Views</th>
		<th>Last post</th>
	</tr>
	{% for topic in topic_list %}
	<tr>
		<td class="activity">
			<img src="{{ media_url }}beastly/img/icons/quote-grey.png" alt="rec" />
		</td>
		<td class="cell2">
			<a href="/beastly/forums/{{ forum.id }}/topics/{{ topic.id }}">{{ topic.title }}</a>
		</td>
		<td>
			<p>{{ topic.post_set.count }}</p>
		</td>
		<td>
			<p>{{ topic.views }}</p>
		</td>
		<td class="last_post no_desc">
			{% if topic.latest_post %}
			<p>{{ topic.latest_post.added|timesince }} ago by <span class="author">{{ topic.latest_post.user.username }}</span> (<a href="/beastly/forums/{{ topic.forum.id }}/topics/{{ topic.id }}/?page={{ topic.latest_post.count|get_page }}">view</a>)</p>
			{% else %}
			<p>never ago</p>
			{% endif %}
		</td>
	</tr>
	{% endfor %}
</table>
{% if user.is_authenticated %}
<p class="new topic"><a href="/beastly/forums/{{ forum.id }}/topics/new">New Topic</a></p>
{% endif %}
{% endblock %}
